/**
 * @author 李民康
 * @date 2024/12/4 16:45:58
 */
import java.math.BigDecimal;

public class Fruit {
    private String name;
    private BigDecimal pricePerKg;

    public Fruit(String name, BigDecimal pricePerKg) {
        this.name = name;
        this.pricePerKg = pricePerKg;
    }

    public String getName() {
        return name;
    }

    public BigDecimal getPricePerKg() {
        return pricePerKg;
    }

    // 计算总价，接收斤数
    public BigDecimal getTotalPrice(int kg) {
        BigDecimal kgBigDecimal = new BigDecimal(kg);
        return pricePerKg.multiply(kgBigDecimal);
    }
}
